package com.jeesite.modules.ocr.front;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Base64;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.jeesite.modules.ocr.utils.AIKitsOCRDemoUtils;
import com.jeesite.modules.ocr.utils.AIKitsOCRUtils;
import com.jeesite.modules.ocr.utils.AIKitsOCRUtils.OCRAPI;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
@RestController
@RequestMapping(value = "${frontPath}/v2")
@Api(tags = "华为盘古OCR识别48种通用API")
public class OcrHuaWeiAiKitsFontController {

	/**
	 * 通用表格识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "通用表格识别")
	@RequestMapping(value = {"recognizeGeneralTable" })
	public String recognizeGeneralTable(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.通用表格识别, "123", json);
	}
	

	/**
	 * RecognizeVatInvoice 增值税发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "增值税发票识别")
	@RequestMapping(value = {"recognizeVatInvoice" })
	public String recognizeVatInvoice(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.增值税发票识别, "123", json);
	}

	/**
	 * 发票验真
	 */
	@ApiOperation(value = "发票验真")
	@RequestMapping(value = {"recognizeInvoiceVerification" })
	public String recognizeInvoiceVerification(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.发票验真, "123", json);
	}

	/**
	 * 通用文字识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "通用文字识别")
	@RequestMapping(value = {"recognizeGeneralText" })
	public String recognizeGeneralText(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\",  \"detect_direction\":true,  \"quick_mode\":false }";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.通用文字识别, "123", json);
	}

	/**
	 * 网络图片识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "网络图片识别")
	@RequestMapping(value = {"recognizeWebImage" })
	public String recognizeWebImage(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.网络图片识别, "123", json);
	}

	/**
	 * 智能文档解析
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "智能文档解析")
	@RequestMapping(value = {"recognizeSmartDocumentRecognizer" })
	public String recognizeSmartDocumentRecognizer(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.通用文字识别, "123", json);
	}

	/**
	 * 防疫健康码识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "防疫健康码识别")
	@RequestMapping(value = {"recognizeHealthCode" })
	public String recognizeHealthCode(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.通用文字识别, "123", json);
	}

	/**
	 * 定额发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "定额发票识别")
	@RequestMapping(value = {"recognizeQuotaInvoice" })
	public String recognizeQuotaInvoice(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.定额发票识别, "123", json);
	}

	/**
	 * 身份证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "身份证识别")
	@RequestMapping(value = {"recognizeIdCard" })
	public String recognizeIdCard(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.身份证识别, "123", json);
	}

	/**
	 * 手写文字识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@ApiOperation(value = "手写文字识别")
	@RequestMapping(value = {"recognizeHandwriting" })
	public String recognizeHandwriting(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.手写文字识别, "123", json);
	}

	/**
	 * 印章识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeSeal(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.印章识别, "123", json);
	}

	/**
	 * 行驶证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeVehicleLicense(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.行驶证识别, "123", json);
	}

	/**
	 * 道路运输证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeTransportationLicense(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.道路运输证识别, "123", json);
	}

	/**
	 * 出租车发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeTaxiInvoice(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.出租车发票识别, "123", json);
	}

	/**
	 * 智能分类识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeAutoClassification(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.智能分类识别, "123", json);
	}

	/**
	 * 车辆通行费发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeTollInvoice(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.车辆通行费发票识别, "123", json);
	}

	/**
	 * 机动车销售发票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeMvsInvoice(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.机动车销售发票识别, "123", json);
	}

	/**
	 * 车牌识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeLicensePlate(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.车牌识别, "123", json);
	}

	/**
	 * 飞机行程单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeFlightItinerary(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.飞机行程单识别, "123", json);
	}

	/**
	 * 营业执照识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeBusinessLicense(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.营业执照识别, "123", json);
	}

	/**
	 * 驾驶证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeDriverLicense(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.驾驶证识别, "123", json);
	}

	/**
	 * 名片识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeBusinessCard(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.名片识别, "123", json);
	}

	/**
	 * 火车票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeTrainTicket(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.火车票识别, "123", json);
	}

	/**
	 * VIN码识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeVin(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.VIN码识别, "123", json);
	}

	/**
	 * 护照识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizePassport(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.护照识别, "123", json);
	}

	/**
	 * 银行卡识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeBankcard(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.通用文字识别, "123", json);
	}

	/**
	 * 保险单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeInsurancePolicy(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.银行卡识别, "123", json);
	}

	/**
	 * 财务报表识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeFinancialStatement(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.财务报表识别, "123", json);
	}

	/**
	 * 道路运输从业资格证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeQualificationCertificate(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.道路运输从业资格证识别, "123", json);
	}

	/**
	 * 电子面单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeWaybillElectronic(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.电子面单识别, "123", json);
	}

	/**
	 * 核酸检测记录识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizePcrTestRecord(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.核酸检测记录识别, "123", json);
	}

	/**
	 * 自定义模板OCR
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeCustomTemplate(String project_id) throws IOException {

		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.自定义模板OCR, "123", json);
	}

	/**
	 * 泰文身份证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeThailandIdcard(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.泰文身份证识别, "123", json);
	}

	/**
	 * 泰国车牌识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeThailandLicensePlate(String project_id) throws IOException {

		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.泰国车牌识别, "123", json);
	}

	/**
	 * 车辆合格证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeVehicleCertificate(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.车辆合格证识别, "123", json);
	}

	/**
	 * 承兑汇票识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeAcceptanceBill(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.承兑汇票识别, "123", json);
	}

	/**
	 * 不动产证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeRealEstateCertificate(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.不动产证识别, "123", json);
	}

	/**
	 * 哥伦比亚身份证识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeColombiaIdCard(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.哥伦比亚身份证识别, "123", json);
	}

	/**
	 * 户口本识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeHouseholdRegister(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.户口本识别, "123", json);
	}

	/**
	 * 银行回单识别
	 * 
	 * @return
	 * @throws IOException
	 */
	@SuppressWarnings("deprecation")
	public String recognizeBankReceipt(String project_id) throws IOException {
		String base64 = AIKitsOCRDemoUtils
				.convertImageToBase64("D:\\History\\2024\\52-侯成力-大模型开发\\01-15天\\13-样本集\\假样本-01.png");
		String json = "{\"image\":\"" + base64 + "\"}";
		return AIKitsOCRUtils.aiKitOCR(OCRAPI.银行回单识别, "123", json);
	}
}
